-- sky_medal
-- created by huangr
-- 遗迹建筑功能-勋章

return {
    canDevelop = function(id)
        return true;
    end,

    -- 获取描述
    getDesc = function(desc, id)
        local level = SkyRelicFunctionM.getLevel(id);

        local techInfo = SkyRelicFunctionM.query(id, "tech");

        local props;
        if type(techInfo) == "table" then
            if techInfo["prop"] then
                props = table.deepcopy(techInfo["prop"]);
            end
        elseif type(techInfo) == "string" then
            -- 配置了公式
            local formuaName = techInfo;

            props = FormulaM.invoke(formuaName, level);
        end

        local fightAbility = 0;
        local skyAttib = 0;
        local ratio = 0;
        if id == 201 then
            -- 骨头勋章
            for _, arr in pairs(props) do
                if arr[1] == 1000 and arr[2] == "fight_ability" then
                    fightAbility = arr[3];
                end
            end
            desc = string.gsub(desc, "{0}", tostring(fightAbility));
        elseif id == 202 or id == 203 or id == 204 or id == 205 then
            -- 圣骑士勋章, 血族勋章,爆破勋章, 解谜者勋章
            for _, arr in pairs(props) do
                if arr[1] == 1000 and arr[2] == "fight_ability" then
                    fightAbility = arr[3];
                else
                    skyAttib = arr[3];
                end
            end

            desc = string.gsub(desc, "{0}", tostring(fightAbility));
            desc = string.gsub(desc, "{1}", tostring(skyAttib));
        elseif id == 206 then
            -- 狩猎者勋章
            for _, arr in pairs(props) do
                if arr[1] == 1004 and arr[2] == 4 then
                    ratio = arr[3] / 10;
                end
            end
            desc = string.gsub(desc, "{0}", tostring(ratio));

        elseif id == 207 then
            -- 航海家勋章
            for _, arr in pairs(props) do
                if arr[1] == 1007 and arr[2] == "all" then
                    ratio = arr[3] / 10;
                end
            end

            desc = string.gsub(desc, "{0}", tostring(ratio));
        elseif id == 208 then
            -- 学者勋章
            for _, arr in pairs(props) do
                if arr[1] == 1016 and arr[2] == "boss" then
                    ratio = arr[3] / 10;
                end
            end

            desc = string.gsub(desc, "{0}", tostring(ratio));
        elseif id == 209 then
            -- 奥鲁维勋章
            for _, arr in pairs(props) do
                if arr[1] == 1017 and arr[2] == 2 then
                    ratio = arr[3] / 10;
                end
            end
            desc = string.gsub(desc, "{0}", tostring(ratio));

        elseif id == 210 then
            -- 卡纳斯勋章
            for _, arr in pairs(props) do
                if arr[1] == 1017 and arr[2] == 1 then
                    ratio = arr[3] / 10;
                end
            end

            desc = string.gsub(desc, "{0}", tostring(ratio));
        elseif id == 211 then
            for _, arr in pairs(props) do
                if arr[1] == 1017 and arr[2] == 3 then
                    ratio = arr[3] / 10;
                end
            end

            desc = string.gsub(desc, "{0}", tostring(ratio));
        elseif id == 212 then
            for _, arr in pairs(props) do
                if arr[1] == 1017 and arr[2] == 4 then
                    ratio = arr[3] / 10;
                end
            end

            desc = string.gsub(desc, "{0}", tostring(ratio));
        end

        return desc;
    end,
};